#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Miguel Silva, 6311
Estrutura de Dados e Algoritmos
Engenharia Informática 
2012/2013
"""

import SortingAlgorithms
import sys

if __name__ == "__main__":
    
    algorithm = sys.argv[1]
    start = int(sys.argv[2])
    stop = int(sys.argv[3])
    step = int(sys.argv[4])
    print "Algorithm : {0}\nStart : {1}\nStop : {2}\nStep : {3}".format(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4])
    if isinstance(start, int) == True and isinstance(stop, int) == True and isinstance(step, int) == True:
        if algorithm == "bubblesort":
            #SortingAlgorithms.Protocol_Bubblesort(10, 350, 5)
            SortingAlgorithms.Protocol_Bubblesort(start, stop, step)
        elif algorithm == "insertionsort":
            SortingAlgorithms.Protocol_Insertionsort(start,stop,step)
            print 'ins'
        elif algorithm == "quicksort":
            SortingAlgorithms.Protocol_Quicksort(start,stop,step)
        elif algorithm == "heapsort":
            SortingAlgorithms.Protocol_Heapsort(start,stop,step)
        elif algorithm == "mergesort":
            SortingAlgorithms.Protocol_Mergesort(start,stop,step)
        else:
            print "Erro no algoritmo!"
    else:
        print "Valores inválidos"